#ifndef __CONTROLLOR_H__
#define __CONTROLLOR_H__

#include "serial.h"
#include "pid_controllor.h"
#include <iostream>
#include <memory>
#include <thread>
#include <atomic>
#include "connector.h"

class controllor
{
public:
    controllor(const std::string& port_name = "/dev/ttyUSB0");
    
    ~controllor();

    void set_connector(const std::shared_ptr<connector<float, float, float, int>> &con);

    void start(void);

    void stop(void);

    void update_json_param(void);

private:
    std::shared_ptr<serial_ctl>     serial_;
    pid_ctl                         forward_ctl_;
    pid_ctl                         yaw_ctl_;
    std::thread                     t_;
    std::atomic<bool>               is_stop_{false};
    std::shared_ptr<connector<float, float, float, int>> pos_con_;
    float                           forward_offset_ = 50;
    float                           yaw_offset_ = 0;
    bool                            runtime_update_ = false;
};

#endif